home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48_2 / rpl.unt < prev    next >
Internet Message Format  |  1991-04-12  |  39KB

  1. From en.ecn.purdue.edu!noose.ecn.purdue.edu!samsung!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!liuida!ide10!d88joave 19 Feb 91 01:07:36 GMT
  2. Path: en.ecn.purdue.edu!noose.ecn.purdue.edu!samsung!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!liuida!ide10!d88joave
  3. From: d88joave@IDA.LiU.SE (Joakim A Verona)
  4. Newsgroups: comp.sys.handhelds
  5. Subject: RPL unthreader for HP48sx intro
  6. Message-ID: <D88JOAVE.91Feb19020736@ide10.IDA.LiU.SE>
  7. Date: 19 Feb 91 01:07:36 GMT
  8. Sender: news@ida.liu.se (News Subsystem)
  9. Distribution: comp
  10. Organization: CIS Dept, University of Linkoping, Sweden
  11. Lines: 281
  12.  
  13. Many people have expressed an interest in my HP48sx RPL unthreader, so
  14. here it is!
  15.  
  16. The files are all in a shell archive, so just type 'sh _filename_' to
  17. extract the following files:
  18.  
  19. unthread.c / main c prog 
  20. unthread.h / header file, containing constants used in unthread.c 
  21. readinf.c / The HP-internals file manager, owned by unthread.  
  22. hdump2hpbin / a program to convert hexdumps as given by the internal debugger
  23.         / to HP-binay files.
  24. makefile    / to make the targets unthread and hdump2hpbin
  25.  
  26. You also need the HP internals file posted recently, to get the info
  27. routines working. The file should be named 'hpint'.
  28.  
  29. #General information:
  30.  
  31. The purpose of all these programs are to facilitate the dissasembly of
  32. the binary structure of RPL programs. 
  33.  
  34. Type 'make' to make all targets.
  35.  
  36. I've only compiled and run the programs on a sun sparc station, but I
  37. dont believe I use any magic, so they should run nicely on any
  38. comparable system. If you encounter any problems, please try to find
  39. where the problem lies, and inform me.
  40.  
  41. #About unthread:
  42.  
  43. To use unthread, download a binary file, and type 'unthread
  44. _filename_'.  You will be greeted by a display like this:
  45.  
  46. odal2 d88joave chaos 5>> unthread eqbin 
  47. Reading info
  48. Scanning eqbin
  49. reading 65544 bytes
  50. File read ok
  51. HPHP48-E
  52. 00010:02B40 LIBRARY        |  
  53. 00015:018DB size           |
  54. 0001A:9460E libname        |  'FIN   :Finance'
  55. 0003A:0010E libnum         |
  56. 0003D:01734 hash           |
  57. 00042:0157C msg            |
  58. 00047:017F1 link           |
  59. 0004C:000DF config         |
  60. -- msg table --------------+
  61. 015BE:029E8 ARRAY          |    
  62. 015C3:00107 size           |
  63. 015C8:02A2C STRING         |
  64. 015CD:00001 #dims          |
  65. 015D2:00007 dim            |
  66. -- array start ------------+
  67. 015D7:0001B size           |
  68. 015DC:06F4E strdat         |    "No Solution"
  69. 015F2:0002D size           |
  70. 015F7:E614D strdat         |    "Many or No Solutions"
  71. 0161F:00023 size           |
  72. 01624:92549 strdat         |    "I%YR/PYR      -100"
  73. 01642:00017 size           |
  74. 01647:66E49 strdat         |    "Invalid N"
  75. 01659:0001B size           |
  76. 0165E:66E49 strdat         |    "Invalid PYR"
  77. 01674:00025 size           |
  78. 01679:66E49 strdat         |    "Invalid #Periods"
  79. 01699:00031 size           |
  80. 0169E:46E55 strdat         |    "Undefined TVM Variable"
  81.  
  82. -- array end -------------+
  83. -- hash table -------------+
  84. 01771:02A4E hashtable      |
  85. 01776:000C2 size           |
  86. 0177B:00000 hashoffs       |  Entry 0 nonexistant
  87. 01780:00000 hashoffs       |  Entry 1 nonexistant
  88. 01785:0004B hashoffs       |  Entry 2 at 17d0
  89. 0178A:00000 hashoffs       |  Entry 3 nonexistant
  90. 0178F:0004C hashoffs       |  Entry 4 at 17db
  91. 01794:00056 hashoffs       |  Entry 5 at 17ea
  92. 01799:00073 hashoffs       |  Entry 6 at 180c
  93. 0179E:00000 hashoffs       |  Entry 7 nonexistant
  94. 017A3:00000 hashoffs       |  Entry 8 nonexistant
  95. 017A8:00000 hashoffs       |  Entry 9 nonexistant
  96. 017AD:00000 hashoffs       |  Entry a nonexistant
  97. 017B2:00000 hashoffs       |  Entry b nonexistant
  98. 017B7:00000 hashoffs       |  Entry c nonexistant
  99. 017BC:00000 hashoffs       |  Entry d nonexistant
  100. 017C1:00000 hashoffs       |  Entry e nonexistant
  101. 017C6:00000 hashoffs       |  Entry f nonexistant
  102. -- name table -------------+
  103. 017CB:00054 size           |
  104. 00051:010E8 name entry     |  'TVM'
  105. 017D8:00000 xlib           |
  106. 00051:010E8 name entry     |  'AMORT'
  107. 017E7:00004 xlib           |
  108. 00051:010E8 name entry     |  'TVMBEG'
  109. 017F8:00001 xlib           |
  110. 00051:010E8 name entry     |  'TVMEND'
  111. 01809:00002 xlib           |
  112. 00051:010E8 name entry     |  'TVMROOT'
  113. 0181C:00003 xlib           |
  114. -- Config for XLIB 270d ---+
  115. 0012B:02D9D PROGRAM        |    <<
  116. 00130:02911 SYSTEM_BINARY  |      <10e>
  117. 0013A:21C6F romobj         |      Internal ATTACH (1:Syst Bin)
  118. 0013F:0312B endprog        |    >>
  119. -- link table -------------+
  120. 01838:02A4E linktable      |
  121. 0183D:000AF size           |
  122. 01842:FE816 linkoffs       |  xlib 0d at 58
  123. 01847:FE832 linkoffs       |  xlib 1d at 79
  124. 0184C:FE84D linkoffs       |  xlib 2d at 99
  125. 01851:FE86A linkoffs       |  xlib 3d at BB
  126. 01856:FE8B6 linkoffs       |  xlib 4d at 10C
  127. 0185B:FE8E9 linkoffs       |  xlib 5d at 144
  128. 01860:FEAC7 linkoffs       |  xlib 6d at 327
  129. 01865:FEAFB linkoffs       |  xlib 7d at 360
  130. -- Code for XLIB 270d 0d --+
  131. 00058:02D9D PROGRAM        |    <<
  132. 0005D:18A1E romobj         |      save last RPL token, stack size, clear @706FD.S /=  No_Args
  133. 00062:02E92 XLIB_NAME      |      XLIB 270d 5d
  134. 0006D:0312B endprog        |    >>
  135. -- Code for XLIB 270d 1d --+
  136. 00079:02D9D PROGRAM        |    <<
  137. 0007E:18A1E romobj         |      save last RPL token, stack size, clear @706FD.S /=  No_Args
  138. 00083:64BC6 romobj         |      <3Eh>               /:  Short_3eh
  139. 00088:53725 romobj         |      Set user flag   (1:Syst Bin) /:  Setflag_q
  140. 0008D:0312B endprog        |    >>
  141. -- Code for XLIB 270d 2d --+
  142. 00099:02D9D PROGRAM        |    <<
  143. 0009E:18A1E romobj         |      save last RPL token, stack size, clear @706FD.S /=  No_Args
  144. 000A3:64BC6 romobj         |      <3Eh>               /:  Short_3eh
  145. 000A8:53755 romobj         |      Clear user flag (1:Syst Bin) /=  Clear_user_flag
  146. 000AD:0312B endprog        |    >>
  147. -- Code for XLIB 270d 3d --+
  148. 000BB:02D9D PROGRAM        |    <<
  149. 000C0:18ECE romobj         |      Save last RPL token, verify DEPTH >= 1 and check args. 
  150. 000C5:0402B romobj         |      <6h>                /=  Short_6
  151. 000CA:02E92 XLIB_NAME      |      XLIB 270d 31d
  152. 000D5:04053 romobj         |      <Ah>                /=  Short_0ah
  153. 000DA:02E92 XLIB_NAME      |      XLIB 270d 30d
  154. 000E5:0312B endprog        |    >>
  155. -- Code for XLIB 270d 4d --+
  156. 0010C:02D9D PROGRAM        |    <<
  157. 00111:18ECE romobj         |      Save last RPL token, verify DEPTH >= 1 and check args. 
  158. 00116:03FF9 romobj         |      <1h>                /:  Short_1
  159. 0011B:02E92 XLIB_NAME      |      XLIB 270d 9d
  160. 00126:0312B endprog        |    >>
  161. -- Code for XLIB 270d 5d --+
  162. 00144:02D9D PROGRAM        |    <<
  163. 00149:06E97 romobj         |      Place next address on the stack, do not execute /:  Get_value
  164. 0014E:02D9D PROGRAM        |      <<
  165. 00153:02A74 LIST           |        {
  166. 00158:02E48 GLOBAL_NAME    |          'N'
  167. 00161:02E48 GLOBAL_NAME    |          'I%YR'
  168. 00170:02E48 GLOBAL_NAME    |          'PV'
  169. 0017B:02E48 GLOBAL_NAME    |          'PMT'
  170. 00188:02E48 GLOBAL_NAME    |          'FV'
  171. 00193:02A74 LIST           |          {
  172. 00198:02A2C STRING         |            
  173. 0019D:0000D size           |
  174. 001A2:24D41 strdat         |            "AMRT"
  175. 001AA:02D9D PROGRAM        |            <<
  176. 001AF:3EE1A romobj         |              Not found
  177. 001B4:02E92 XLIB_NAME      |              XLIB 270d 4d
  178. 001BF:02E92 XLIB_NAME      |              XLIB 270d 8d
  179. 001CA:0312B endprog        |            >>
  180. 001CF:0312B endlist        |          }
  181. 001D4:02E48 GLOBAL_NAME    |          'PYR'
  182. 001E1:02A74 LIST           |          {
  183. 001E6:02D9D PROGRAM        |            <<
  184. 001EB:40788 romobj         |              Null Program
  185. 001F0:02A2C STRING         |              
  186. 001F5:0000B size           |
  187. 001FA:74542 strdat         |              "BEG"
  188. 00200:64BC6 romobj         |              <3Eh>               /:  Short_3eh
  189. 00205:53778 romobj         |              User flag set? (1:Syst Bin) -> True/False /:  Test_user_flag
  190. 0020A:3EC99 romobj         |              Not found
  191. 0020F:0312B endprog        |            >>
  192. 00214:02D9D PROGRAM        |            <<
  193. 00219:3EE1A romobj         |              Not found
  194. 0021E:02E92 XLIB_NAME      |              XLIB 270d 1d
  195. 00229:02E92 XLIB_NAME      |              XLIB 270d 10d
  196. 00234:0312B endprog        |            >>
  197. 00239:0312B endlist        |          }
  198. 0023E:02A74 LIST           |          {
  199. 00243:02D9D PROGRAM        |            <<
  200. 00248:40788 romobj         |              Null Program
  201. 0024D:02A2C STRING         |              
  202. 00252:0000B size           |
  203. 00257:44E45 strdat         |              "END"
  204. 0025D:64BC6 romobj         |              <3Eh>               /:  Short_3eh
  205. 00262:53778 romobj         |              User flag set? (1:Syst Bin) -> True/False /:  Test_user_flag
  206. 00267:03AF2 romobj         |              Internal NOT (1:True/False)  /:  Not
  207. 0026C:3EC99 romobj         |              Not found
  208. 00271:0312B endprog        |            >>
  209. 00276:02D9D PROGRAM        |            <<
  210. 0027B:3EE1A romobj         |              Not found
  211. 00280:02E92 XLIB_NAME      |              XLIB 270d 2d
  212. 0028B:02E92 XLIB_NAME      |              XLIB 270d 11d
  213. 00296:0312B endprog        |            >>
  214. 0029B:0312B endlist        |          }
  215. 002A0:0312B endlist        |        }
  216. 002A5:06E97 romobj         |        Place next address on the stack, do not execute /:  Get_value
  217. 002AA:02D9D PROGRAM        |        <<
  218. 002AF:02E92 XLIB_NAME      |          XLIB 270d 15d
  219. 002BA:3918A romobj         |          Not found
  220. 002BF:0312B endprog        |        >>
  221. 002C4:418D4 romobj         |        Store_7062d
  222. 002C9:151A6 romobj         |        Not found
  223. 002CE:06E97 romobj         |        Place next address on the stack, do not execute /:  Get_value
  224. 002D3:02E92 XLIB_NAME      |        XLIB 270d 6d
  225. 002DE:41944 romobj         |        Store_7063c
  226. 002E3:06E97 romobj         |        Place next address on the stack, do not execute /:  Get_value
  227. 002E8:02E92 XLIB_NAME      |        XLIB 270d 16d
  228. 002F3:41984 romobj         |        Store_70646
  229. 002F8:06E97 romobj         |        Place next address on the stack, do not execute /:  Get_value
  230. 002FD:390A4 romobj         |        Not found
  231. 00302:419C4 romobj         |        Store_70655
  232. 00307:0312B endprog        |      >>
  233. 0030C:02E92 XLIB_NAME      |      XLIB 270d 15d
  234. 00317:40F86 romobj         |      Not found
  235. 0031C:0312B endprog        |    >>
  236.  
  237. Etc. I have cut out bits and pieces of the above. The first column
  238. in the left field (infofield) is a nybble offset into the file, which
  239. translates easily into addresses, according to the following formula:
  240. startaddr+offset-16.  The second column contains the data at that
  241. address, in the reverse order of how it would appear in memory(see
  242. below). The third collumn contains a label describing the data.  If
  243. it's a type descriptor the label apears in capitals. You would
  244. probably need the Internals Guide by Dereck Nickel to find this
  245. information useful. The right field contains an emulation of the HP
  246. print format.
  247.  
  248. #About hdump2hpbin:
  249.  
  250. This program takes a hexdump in the format given by the internal
  251. debugger i.e 80000:0123456789ABDCDE and turns it into a HP-binary
  252. file, so you can look at it with unthread. Note that some Page_Magic
  253. occurs when your in the debugger, so you can only look at the first
  254. 32Kb of portspace this way.  You can of course use the various peek
  255. routines available and download ROM that way if you like.
  256.  
  257. #About the code:
  258.  
  259. Okay, there is room for improvement here. I would greatly appreciate
  260. any comments and concrete ideas for enhancment.
  261.  
  262. Some improvements I can think of that I might do someday includes
  263. an  info file for xlibs (XLIB 1792 2 is a rather cryptic name)
  264. using hashtables instead of binary trees in the info section
  265.     (bintrees are rather inefective to insert sorted keys in)
  266.     (but I had the routines lying about)
  267. dissasembly of machine language.
  268.  
  269. #About copyright and other boring stuff:
  270.  
  271. This program is of course Public Domain. You are hereby granted the
  272. right to do whatever you please with these programs, as long as you
  273. don't deprive any other sentient being(s) of the same right.
  274.  
  275. Especialy you may improve the code, and especialy especialy you may
  276. send me those improvements.
  277.  
  278. You should also be aware that actually using these programs will
  279. result in any sort of catastrophe up to and including the destruction
  280. of the entire world as we know it. Notice that I didn't tell you to
  281. use my programs above, merely how to.
  282.  
  283.  
  284. --
  285. ==============================================================================
  286. ! Joakim Verona LiTH ! Snail: soergaardsgatan 11 ! Email:                    !
  287. ! Voice: 013/178107  !        58239 Linkoeping   ! d88joave@kolix.ida.liu.se !
  288. ==============================================================================
  289. --
  290. ==============================================================================
  291. ! Joakim Verona LiTH ! Snail: soergaardsgatan 11 ! Email:                    !
  292. ! Voice: 013/178107  !        58239 Linkoeping   ! d88joave@kolix.ida.liu.se !
  293. ==============================================================================
  294.  
  295. From en.ecn.purdue.edu!noose.ecn.purdue.edu!samsung!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!liuida!ide10!d88joave 19 Feb 91 01:10:13 GMT
  296. Path: en.ecn.purdue.edu!noose.ecn.purdue.edu!samsung!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!liuida!ide10!d88joave
  297. From: d88joave@IDA.LiU.SE (Joakim A Verona)
  298. Newsgroups: comp.sys.handhelds
  299. Subject: RPL unthreader for HP48sx source
  300. Message-ID: <D88JOAVE.91Feb19021013@ide10.IDA.LiU.SE>
  301. Date: 19 Feb 91 01:10:13 GMT
  302. Sender: news@ida.liu.se (News Subsystem)
  303. Distribution: comp
  304. Organization: CIS Dept, University of Linkoping, Sweden
  305. Lines: 1027
  306.  
  307. #! /bin/sh
  308. # This is a shell archive.  Remove anything before this line, then unpack
  309. # it by saving it into a file and typing "sh file".  To overwrite existing
  310. # files, type "sh file -c".  You can also feed this as standard input via
  311. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  312. # will see the following message at the end:
  313. #        "End of shell archive."
  314. # Contents:  hdump2hpbin.c makefile readinf.c unthread.c unthread.h
  315. # Wrapped by projpd@majestix on Tue Feb 19 02:01:45 1991
  316. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  317. if test -f hdump2hpbin.c -a "${1}" != "-c" ; then 
  318.   echo shar: Will not over-write existing file \"hdump2hpbin.c\"
  319. else
  320. echo shar: Extracting \"hdump2hpbin.c\" \(953 characters\)
  321. sed "s/^X//" >hdump2hpbin.c <<'END_OF_hdump2hpbin.c'
  322. X#include <stdio.h>
  323. X#include <sys/types.h>
  324. X#include <sys/stat.h>
  325. X#include <fcntl.h>
  326. X
  327. X
  328. X/*******************************/
  329. X/* takes a hp48 memdump as     */
  330. X/* given by the internal debugger */
  331. X/* and turns it into a binary  */
  332. X/* file.                       */
  333. X/*******************************/
  334. X
  335. X
  336. X
  337. X
  338. Xunsigned char swap_n(c)
  339. X     unsigned char c;
  340. X{
  341. X  return((c>>4)+(c<<4));
  342. X}
  343. X
  344. Xint noteof()
  345. X{
  346. X  
  347. X  int inp=getchar();
  348. X  ungetc(inp, stdin);
  349. X  return(inp!=EOF);
  350. X}
  351. X  
  352. Xmain()
  353. X{
  354. X  int loop, intc;
  355. X  int flg=!EOF;
  356. X  long f1, f2;
  357. X  unsigned char sep;
  358. X  unsigned char cout;
  359. X  printf("HPHP48-E");
  360. X  while (noteof())
  361. X    {
  362. X      flg=scanf("%*[^0-9a-fA-F]");
  363. X
  364. X      scanf("%5x%c%", &f1, &sep);
  365. X      /*printf(" flg:%d ", flg);*/
  366. X
  367. X     /* printf("%x%c%", f1, sep);*/
  368. X      if (noteof())
  369. X    for (loop=0; loop<8; loop++)
  370. X      {
  371. X        scanf("%2x", &intc);
  372. X        cout=0xff&(unsigned char)intc;
  373. X        
  374. X       /* printf("%2x",cout);*/
  375. X        putchar(swap_n(cout));
  376. X
  377. X      }
  378. X    }
  379. X}
  380. X
  381. X
  382. X
  383. X
  384. X
  385. X
  386. X
  387. X
  388. X
  389. X
  390. X
  391. END_OF_hdump2hpbin.c
  392. if test 953 -ne `wc -c <hdump2hpbin.c`; then
  393.     echo shar: \"hdump2hpbin.c\" unpacked with wrong size!
  394. fi
  395. # end of overwriting check
  396. fi
  397. if test -f makefile -a "${1}" != "-c" ; then 
  398.   echo shar: Will not over-write existing file \"makefile\"
  399. else
  400. echo shar: Extracting \"makefile\" \(161 characters\)
  401. sed "s/^X//" >makefile <<'END_OF_makefile'
  402. XCFLAGS = -g
  403. Xunthread:    unthread.o unthread.h readinf.o
  404. X    cc -o unthread unthread.o readinf.o
  405. Xhdump2hpbin:    hdump2hpbin.c
  406. X    cc -o hdump2hpbin hdump2hpbin.c
  407. X
  408. X
  409. X
  410. X
  411. X
  412. X
  413. X
  414. X
  415. X
  416. X
  417. END_OF_makefile
  418. if test 161 -ne `wc -c <makefile`; then
  419.     echo shar: \"makefile\" unpacked with wrong size!
  420. fi
  421. # end of overwriting check
  422. fi
  423. if test -f readinf.c -a "${1}" != "-c" ; then 
  424.   echo shar: Will not over-write existing file \"readinf.c\"
  425. else
  426. echo shar: Extracting \"readinf.c\" \(2040 characters\)
  427. sed "s/^X//" >readinf.c <<'END_OF_readinf.c'
  428. X#include <stdio.h>
  429. X#include <sys/types.h>
  430. X#include <fcntl.h>
  431. X#include <strings.h>
  432. X
  433. X#define NIL NULL
  434. X#define SMALLEST -1
  435. X  
  436. X  
  437. X  typedef struct bintree
  438. X{
  439. X  int key;
  440. X  char *data;
  441. X  struct bintree *left, *right;
  442. X};
  443. X
  444. Xstruct bintree *inforoot;
  445. X
  446. Xstruct bintree *makenode()
  447. X{
  448. X  struct bintree *retval=(struct bintree *)malloc(sizeof(struct bintree));
  449. X  retval->left=NIL;
  450. X  retval->right=NIL;
  451. X  retval->key=SMALLEST;
  452. X  return(retval);
  453. X}
  454. X
  455. X
  456. Xinsert_node(root, key, data)
  457. X     struct bintree *root;
  458. X     char *data;
  459. X     int key;
  460. X{
  461. X  struct bintree **nodehead=&(root->right);
  462. X  while ((*nodehead)!=NIL && ((*nodehead)->key!=key))
  463. X    nodehead= (( (*(*nodehead)).key)<key) ? &((*(*nodehead)).left):&((*(*nodehead)).right);
  464. X  if (*nodehead==NIL)
  465. X    *nodehead=makenode();
  466. X  (*nodehead)->key=key;
  467. X  (*nodehead)->data=data;
  468. X}
  469. X
  470. Xstruct bintree *find_node(root, key)
  471. X     struct bintree *root;
  472. X     int key;
  473. X{
  474. X  struct bintree **nodehead=&(root->right);
  475. X  while ((*nodehead)!=NIL && ((*nodehead)->key!=key))
  476. X    nodehead= (( (*(*nodehead)).key)<key) ? &((*(*nodehead)).left):&((*(*nodehead)).right);
  477. X  return(*nodehead);
  478. X}
  479. X
  480. X
  481. X
  482. Xint noteof(file)
  483. X     FILE *file;
  484. X{
  485. X  return(!feof(file));
  486. X};
  487. X
  488. Xstruct bintree *read_infofile(name)
  489. X     char * name;
  490. X{
  491. X  FILE *infile;
  492. X  int flag=1, n, cur_key;
  493. X  struct bintree *myroot=makenode();
  494. X  char *cur_line;
  495. X  infile = fopen(name, "r");
  496. X  if (infile)
  497. X    while(noteof(infile))
  498. X      {
  499. X    cur_line=(char *)malloc(80);
  500. X    while (noteof(infile)&&(0==fscanf(infile, "%x%*c%*[ ]%[^\n]", &cur_key, cur_line)))
  501. X    fscanf(infile, "%*[^\n]");
  502. X    if(noteof(infile))
  503. X      {
  504. X        insert_node(myroot, cur_key, cur_line);
  505. X        
  506. X      }
  507. X      }
  508. X  else
  509. X    printf("I told you to have a 'hpint' file!\nBut there is none..\n");
  510. X  return(myroot);
  511. X}
  512. X
  513. X
  514. X
  515. X
  516. X
  517. Xchar *get_infostr(key)
  518. X     int key;
  519. X{
  520. X  struct bintree *found_node;
  521. X  found_node=find_node(inforoot, key);
  522. X  if (found_node==NIL)
  523. X    return("Not found");
  524. X  else
  525. X    return( found_node->data );
  526. X}
  527. X     
  528. X
  529. Xvoid init_info()
  530. X{
  531. X  printf("Reading info\n");
  532. X  inforoot=read_infofile("hpint");
  533. X  
  534. X}
  535. X
  536. X
  537. X
  538. X
  539. X
  540. X
  541. X
  542. X
  543. X
  544. X
  545. X
  546. END_OF_readinf.c
  547. if test 2040 -ne `wc -c <readinf.c`; then
  548.     echo shar: \"readinf.c\" unpacked with wrong size!
  549. fi
  550. # end of overwriting check
  551. fi
  552. if test -f unthread.c -a "${1}" != "-c" ; then 
  553.   echo shar: Will not over-write existing file \"unthread.c\"
  554. else
  555. echo shar: Extracting \"unthread.c\" \(17058 characters\)
  556. sed "s/^X//" >unthread.c <<'END_OF_unthread.c'
  557. X#include <stdio.h>
  558. X#include <sys/types.h>
  559. X#include <sys/stat.h>
  560. X#include <fcntl.h>
  561. X#include "unthread.h"
  562. X  
  563. Xunsigned char *myfilearr;    /* global array for file */
  564. Xint indentlevel=0, myoffset;            /* offset in nybbles */
  565. X
  566. X
  567. X
  568. X#define PROLOG_NOS 25
  569. X
  570. Xstruct 
  571. X{
  572. X  char *name, *printname;
  573. X  int addr, no;
  574. X} prologinfo[PROLOG_NOS] =
  575. X{
  576. X  { "UNKNOWN"      ,"\n"    , NULL , -1 },
  577. X  { "SYSTEM_BINARY",""      , SYSTEM_BINARY      , 20  },
  578. X  { "REAL_NUMBER"  ,""      , REAL_NUMBER        , 0   },
  579. X  { "LONG_REAL"    ,""      , LONG_REAL          , 21  },
  580. X  { "COMPLEX"      ,""      , COMPLEX            , 1   },
  581. X  { "LONG_COMPLEX" ,""      , LONG_COMPLEX       , 22  },
  582. X  { "CHARACTER"    ,"\n"      , CHARACTER          , 24  },
  583. X  { "ARRAY"        ,"\n"    , ARRAY              , 3   },
  584. X  { "LINKED_ARRAY" ,""      , LINKED_ARRAY       , 23  },
  585. X  { "STRING"       ,"\n"    , STRING             , 2   },
  586. X  { "BINARY_INT"   ,"\n"      , BINARY_INT         , 10  },
  587. X  { "LIST"         ,"{\n"   , LIST               , 5   },
  588. X  { "DIRECTORY"    ,"DIR\n" , DIRECTORY          , 15  },
  589. X  { "ALGEBRAIC"    ,""      , ALGEBRAIC          , 9   },
  590. X  { "UNIT"         ,"\n"      , UNIT               , 13  },
  591. X  { "TAGGED"       ,""      , TAGGED             , 12  },
  592. X  { "GRAPHIC"      ,"\n"    , GRAPHIC            , 11  },
  593. X  { "LIBRARY"      ,"\n"    , LIBRARY            , 16  },
  594. X  { "BACKUP"       ,"\n"      , BACKUP             , 17  },
  595. X  { "LIBRARY_DATA" ,"\n"      , LIBRARY_DATA       , 26  },
  596. X  { "PROGRAM"      ,"<<\n"  , PROGRAM            , 8   },
  597. X  { "CODE"         ,"\n"      , CODE               , 25  },
  598. X  { "GLOBAL_NAME"  ,""      , GLOBAL_NAME        , 6   },
  599. X  { "LOCAL_NAME"   ,""      , LOCAL_NAME         , 7   },
  600. X  { "XLIB_NAME"    ,""      , XLIB_NAME          , 14  }
  601. X};
  602. X
  603. X
  604. X
  605. Xunsigned char swap_n(c)
  606. X     unsigned char c;
  607. X{
  608. X  return((c>>4)+(c<<4));
  609. X}
  610. X
  611. Xvoid aargh(str)
  612. X     char *str;
  613. X{
  614. X  printf("%s %s",str,"\nExiting.\n");
  615. X
  616. X  exit(0);
  617. X}
  618. X
  619. Xint readin(name)
  620. X     char *name;
  621. X{
  622. X  int myfilesize;
  623. X  FILE *infile;
  624. X  int filed;
  625. X  struct stat buf;
  626. X  unsigned char *tfp;
  627. X  int tempc;            
  628. X  if ((filed = open(name,O_RDONLY))==-1) 
  629. X     aargh("Could not open file\n");
  630. X  if (fstat(filed, &buf)==-1)
  631. X    aargh("fstat error\n");
  632. X  printf("reading %u bytes\n",buf.st_size);
  633. X  if (!(myfilearr=(unsigned char *)malloc((unsigned)(myfilesize=(long)buf.st_size))))
  634. X    aargh("Could not allocate memory\n");
  635. X  tfp=myfilearr;
  636. X  infile=fdopen(filed, "r");
  637. X  while ((tempc=fgetc(infile))!=EOF)
  638. X    {
  639. X      tempc=(char)0xff&tempc;
  640. X      *(tfp++)=swap_n(tempc);
  641. X    }
  642. X  
  643. X  printf("File read ok\n");
  644. X  return(myfilesize);
  645. X}
  646. X
  647. Xunsigned char get_n(start, offset)
  648. X     int offset;
  649. X     unsigned char*start;
  650. X{
  651. X  unsigned char retval;
  652. X  retval=*(start+(offset>>1));
  653. X  retval=offset&0x1?retval&0xf:((retval&0xf0)>>4);
  654. X  return(retval);
  655. X}
  656. X
  657. Xint get_bin5(start,offset)
  658. X     int offset;
  659. X     unsigned char *start;
  660. X{
  661. X  int retval=0, loop;
  662. X  for(loop=0; loop<5; loop++)
  663. X    {
  664. X      
  665. X      retval+=(get_n(start,offset+loop)<<(4*loop));
  666. X      
  667. X    }
  668. X  return(retval);
  669. X}
  670. X
  671. Xint get_bin2(start,offset)
  672. X     int offset;
  673. X     unsigned char *start;
  674. X{
  675. X  int retval=0, loop;
  676. X  for(loop=0; loop<2; loop++)
  677. X    {
  678. X      
  679. X      retval+=(get_n(start,offset+loop)<<(4*loop));
  680. X      
  681. X    }
  682. X  return(retval);
  683. X}
  684. X
  685. Xint get_binx(binxstart, offset, nonib)
  686. X     unsigned char *binxstart;
  687. X     int offset,nonib;
  688. X{
  689. X  int retval=0, loop;
  690. X  for(loop=0; loop<nonib; loop++)
  691. X    {
  692. X      
  693. X      retval+=(get_n(binxstart,offset+loop)<<(4*loop));
  694. X      
  695. X    }
  696. X  return(retval);
  697. X}
  698. X
  699. Xint print_hps(start, offset, length)
  700. X     unsigned char *start;
  701. X     int offset, length;
  702. X{
  703. X  int loop;
  704. X  for (loop=0; loop<(length*2); loop+=2)
  705. X    {
  706. X      printf ("%c",get_binx(start, offset+loop, (int)2));
  707. X    }
  708. X  return(length*2);
  709. X}
  710. X
  711. Xint find_prolog(prolog)
  712. X     int prolog;
  713. X{
  714. X  int loop;
  715. X  
  716. X  for (loop=1; loop<PROLOG_NOS; loop++)
  717. X    if (prologinfo[loop].addr==prolog) return(loop);
  718. X  return(0);            /* unsuccesful */
  719. X}
  720. X
  721. X
  722. Xint print_size(start, offset)
  723. X     unsigned char *start;
  724. X     int offset;
  725. X{
  726. X  print_beg(start, offset, 5, "size", FORCE_NL);  
  727. X  return(5);
  728. X}
  729. X
  730. Xint print_ascix(start, offset)
  731. X     unsigned char *start;
  732. X     int offset;
  733. X{
  734. X  int strlen=get_bin2(start, offset);
  735. X  if (strlen!=0)
  736. X    {
  737. X      printf("'");
  738. X      print_hps(start, offset+2, strlen);
  739. X      puts("'");
  740. X      return(4+strlen*2);
  741. X    }
  742. X  else
  743. X    {
  744. X      printf("''\n");
  745. X      return(2);
  746. X    }
  747. X}
  748. X
  749. Xint print_ascic(start, offset)
  750. X     unsigned char *start;
  751. X     int offset;
  752. X{
  753. X  int strlen=get_bin2(start, offset);
  754. X  if (strlen!=0)
  755. X    {
  756. X      printf("'");
  757. X      print_hps(start, offset+2, strlen);
  758. X      puts("'");
  759. X      return(2+strlen*2);
  760. X    }
  761. X  else
  762. X    {
  763. X      printf("''\n");
  764. X      return(2);
  765. X    }
  766. X}
  767. X
  768. X
  769. Xvoid pr_infh(n)
  770. X     int n;
  771. X{
  772. X  printf(" ");
  773. X  n=INFOFIELD_L-n-1+12;
  774. X  while((n--)>0)
  775. X    printf("-");
  776. X  printf("+\n");
  777. X}
  778. X
  779. X
  780. Xint print_string(start, offset)
  781. X     unsigned char *start;
  782. X     int offset;
  783. X{
  784. X  int length=get_binx(start, offset, 5);
  785. X  print_size(start, offset);
  786. X  print_beg(start, offset+5, 5, "strdat", indentlevel);
  787. X  printf("\"");
  788. X  print_hps(start, offset+5, (length-5)/2);
  789. X  printf("\"\n");
  790. X  return(length);
  791. X}
  792. X
  793. Xint print_binint(start, offset)
  794. X     unsigned char *start;
  795. X     int offset;
  796. X{
  797. X  int loop, length=get_bin5(start, offset);
  798. X  
  799. X  offset+=print_size(start, offset);
  800. X  print_beg(start, offset, 5, "binintdata", indentlevel);
  801. X  printf("#");
  802. X  for(loop=0; loop<(length-5); loop++)
  803. X    printf("%X", get_n(start, offset+loop));
  804. X  printf("h\n");
  805. X  return(length);
  806. X}
  807. X
  808. Xint print_real(start, offset)
  809. X     unsigned char *start;
  810. X     int offset;
  811. X{
  812. X  return(print_realx(start, offset, REAL_FORM12));
  813. X}
  814. X
  815. X
  816. X
  817. Xint print_realx(start, offset, length)
  818. X     unsigned char *start;
  819. X     int offset, length;
  820. X{
  821. X  int loop;
  822. X  float cf;
  823. X  char gonzaga[20];
  824. X  char *gonz=gonzaga;
  825. X  if (get_n(start, offset+length-1)==MAGIC_MINUS)
  826. X    sprintf(gonz++, "-");
  827. X  sprintf(gonz, "%X.", get_n(start, offset+length-2));
  828. X  gonz+=2;
  829. X  for(loop=length-3; loop>=0; loop--)
  830. X    {
  831. X      if (loop==2)
  832. X    sprintf(gonz++, "E");
  833. X    
  834. X      sprintf(gonz++, "%X", get_n(start, offset+loop));
  835. X    }
  836. X  sscanf(gonzaga, "%f", &cf);
  837. X  printf("%g", cf);
  838. X  printf(" ");
  839. X  return(length);
  840. X}
  841. X       
  842. X
  843. Xint print_complex(start, offset)
  844. X     unsigned char *start;
  845. X     int offset;
  846. X{
  847. X  return(print_complexx(start, offset, REAL_FORM12));
  848. X}
  849. X
  850. Xint print_complexx(start, offset, form)
  851. X     unsigned char *start;
  852. X     int offset, form;
  853. X{
  854. X  printf("Re:");
  855. X  offset+=print_realx(start, offset, form);
  856. X  printf("Im:");
  857. X  offset+=print_realx(start, offset, form);
  858. X  
  859. X  return(2*form);
  860. X}
  861. X
  862. X
  863. Xint print_graphic(start, offset)
  864. X     unsigned char *start;
  865. X     int offset;
  866. X{
  867. X  int  rows, cols, length;
  868. X  print_size(start, offset);
  869. X  length=get_bin5(start, offset);
  870. X  offset+=5;
  871. X  print_beg(start, offset, 5, "#rows", FORCE_NL);
  872. X  rows=get_bin5(start, offset);
  873. X  offset+=5;
  874. X  print_beg(start, offset, 5, "#columns", FORCE_NL);
  875. X  cols=get_bin5(start, offset);
  876. X  offset+=5;
  877. X  print_beg(start, offset, 5, "grdat", FORCE_NL);
  878. X  pr_infh(WHOLE_INFOFIELD);
  879. X  print_sillygraph(start, offset, rows, cols);
  880. X  pr_infh(WHOLE_INFOFIELD);
  881. X  return(length);
  882. X}
  883. X
  884. Xint print_sillygraph(start, offset, rows, cols)
  885. X     unsigned char *start;
  886. X     int offset, rows, cols;
  887. X{
  888. X  int rowloop, colloop, nloop,  nstr;
  889. X  cols=cols/4+((cols%4)?1:0);
  890. X  cols=cols+((cols%2)?1:0);
  891. X  for (rowloop=0; rowloop<rows; rowloop++)
  892. X    {
  893. X      for (colloop=0; colloop<cols; colloop++)
  894. X    {
  895. X      nstr=get_n(start, offset++);
  896. X      for (nloop=0; nloop<4; nloop++)
  897. X        if (nstr&(1<<nloop))
  898. X          printf("#");
  899. X        else
  900. X          printf(" ");
  901. X    }
  902. X      puts("");
  903. X    }
  904. X  puts("");
  905. X}
  906. X    
  907. Xint print_librarydata(start, offset)
  908. X     unsigned char *start;
  909. X     int offset;
  910. X{
  911. X  int oldoffs=offset;
  912. X  offset+=print_size(start, offset);
  913. X  offset+=print_beg(start, offset, 3, "libno", FORCE_NL);
  914. X  offset+=print_beg(start, offset, 2, "datano", FORCE_NL);
  915. X  
  916. X  while (get_binx(start, offset, 5)!=END_OF_LIBRARYDATA)
  917. X    offset+=print_block(start, offset);
  918. X  offset+=print_beg(start, offset, 5,"endlibdat", FORCE_NL);
  919. X  return(offset-oldoffs);
  920. X}
  921. X
  922. X
  923. X  
  924. Xvoid print_spx(no)
  925. X     int no;
  926. X{
  927. X  while((no--)>0)
  928. X    putchar(32);
  929. X}
  930. X
  931. X
  932. Xint print_beg(start, offset, nybbles, typestr, ind)
  933. X     int  offset, nybbles, ind;
  934. X     char *typestr;
  935. X     unsigned char *start;
  936. X{
  937. X  printf("%05.X:%05.X %s", offset, get_binx(start, offset, nybbles) , typestr);
  938. X  print_spx(INFOFIELD_L-strlen(typestr));
  939. X  printf("|");
  940. X  if (ind==FORCE_NL)
  941. X      puts("");
  942. X  else
  943. X      print_spx(ind);
  944. X
  945. X  return(nybbles);
  946. X      
  947. X}
  948. X    
  949. Xint print_algebraic(start, offset)
  950. X     unsigned char *start;
  951. X     int offset;
  952. X{
  953. X  while (get_binx(start, offset, 5)!=END_OF_ALGEBRAIC)
  954. X    offset+=print_block(start, offset);
  955. X  offset+=print_beg(start, offset, 5,"endalg", indentlevel);
  956. X  
  957. X}
  958. Xint print_obj(start, offset, cur_prolog)
  959. X     unsigned char *start;
  960. X     int offset, cur_prolog;
  961. X{
  962. X  int print_block();
  963. X  int print_arry();
  964. X  int endoffs, oldoffs=offset;
  965. X
  966. X  switch (cur_prolog)
  967. X    {
  968. X    case BACKUP :
  969. X      offset+=print_size(start, offset);
  970. X      print_beg(start, offset, 5, "backupname", indentlevel);
  971. X      offset+=print_ascix(start, offset);
  972. X      offset+=print_block(start, offset);
  973. X      break;
  974. X    case DIRECTORY :
  975. X      offset+=print_beg(start, offset, 3, " attach", FORCE_NL);
  976. X      (void)print_beg(start, offset, 5, " offset1", FORCE_NL);
  977. X      endoffs=offset+get_binx(start, offset, 5);
  978. X      offset+=5;
  979. X      do
  980. X    {
  981. X      offset+=print_beg(start, offset, 5, " offset", FORCE_NL);
  982. X      print_beg(start, offset, 5, "DIRENTRY", indentlevel);
  983. X      offset+=print_ascix(start, offset);
  984. X      offset+=print_block(start, offset);
  985. X    }
  986. X      while (offset < endoffs  );
  987. X      break;
  988. X      
  989. X    case BINARY_INT :
  990. X      offset+=print_binint(start, offset);
  991. X      break;
  992. X    case LIST:
  993. X      while (get_binx(start, offset, 5)!=END_OF_LIST)
  994. X    offset+=print_block(start, offset);
  995. X      offset+=print_beg(start, offset, 5,"endlist", indentlevel);
  996. X      printf("}\n");
  997. X      break;
  998. X    case PROGRAM:
  999. X      while (get_binx(start, offset, 5)!=END_OF_PROGRAM)
  1000. X    offset+=print_block(start, offset);
  1001. X      offset+=print_beg(start, offset, 5,"endprog", indentlevel);
  1002. X      printf(">>\n");
  1003. X      break;
  1004. X    case LOCAL_NAME:
  1005. X      offset+=print_ascic(start, offset);
  1006. X      break;
  1007. X    case GLOBAL_NAME:
  1008. X      offset+=print_ascic(start, offset);
  1009. X      break;
  1010. X    case STRING:
  1011. X      offset+=print_string(start, offset);
  1012. X      break;
  1013. X    case REAL_NUMBER:
  1014. X      offset+=print_real(start, offset);
  1015. X      break;
  1016. X    case COMPLEX:
  1017. X      offset+=print_complex(start, offset);
  1018. X      break;
  1019. X    case LONG_REAL:
  1020. X      offset+=print_realx(start, offset, REAL_FORM15);
  1021. X      break;
  1022. X    case LONG_COMPLEX:
  1023. X      offset+=print_complexx(start, offset, REAL_FORM15);
  1024. X      break;
  1025. X    case ARRAY:
  1026. X      offset+=print_array(start, offset);
  1027. X      break;
  1028. X    case LIBRARY :
  1029. X      offset+=print_library(start, offset);
  1030. X      break;
  1031. X    case XLIB_NAME :
  1032. X      offset+=print_xlibname(start, offset);
  1033. X      break;
  1034. X    case SYSTEM_BINARY :
  1035. X      printf("<%x>\n", get_bin5(start, offset));
  1036. X      offset+=5;
  1037. X      break;
  1038. X    case CODE :
  1039. X      print_size(start, offset);
  1040. X      offset+=get_bin5(start, offset);
  1041. X      printf("No dissasembly yet!\n");
  1042. X      break;
  1043. X    case GRAPHIC :
  1044. X      offset+=print_graphic(start, offset);
  1045. X      break;
  1046. X    case CHARACTER :
  1047. X      print_beg(start, offset, 2, "char", indentlevel);
  1048. X      printf("'%c'\n", get_binx(start, offset, 2));
  1049. X      offset+=2;
  1050. X      break;
  1051. X    case LINKED_ARRAY :
  1052. X      print_beg(start, offset, 5, "size", indentlevel);
  1053. X      printf("I dont know how to display this form.\n");
  1054. X      offset+=get_bin5(start, offset);
  1055. X    case ALGEBRAIC :
  1056. X      offset+=print_algebraic(start, offset);
  1057. X      break;
  1058. X    case LIBRARY_DATA :
  1059. X      offset+=print_librarydata(start, offset);
  1060. X      break;
  1061. X    case TAGGED :
  1062. X      offset+=print_ascic(start, offset);
  1063. X      offset+=print_block(start, offset);
  1064. X      break;
  1065. X    case UNIT :
  1066. X      offset+=print_block(start, offset);
  1067. X      offset+=print_block(start, offset);
  1068. X      while (get_binx(start, offset, 5)!=END_OF_TAG)
  1069. X    offset+=print_block(start, offset);
  1070. X      offset+=print_beg(start, offset, 5,"endunit", FORCE_NL);
  1071. X      break;
  1072. X    }
  1073. X  return(offset-oldoffs);
  1074. X}
  1075. X
  1076. X
  1077. Xint print_array(start, offset)
  1078. X     unsigned char *start;
  1079. X     int offset;
  1080. X{
  1081. X  int  cur_prolog_no, length, obj_nos=1, dims, cur_prolog;
  1082. X  print_size(start, offset);
  1083. X  length=get_bin5(start, offset);
  1084. X  offset+=5;
  1085. X  cur_prolog=get_bin5(start, offset);
  1086. X  cur_prolog_no=find_prolog(cur_prolog);
  1087. X  print_beg(start, offset, 5, prologinfo[cur_prolog_no].name , FORCE_NL);
  1088. X  offset+=5;
  1089. X  print_beg(start, offset, 5, "#dims ", FORCE_NL);
  1090. X  dims=get_bin5(start, offset); offset+=5;
  1091. X  while(dims--)
  1092. X    {
  1093. X      print_beg(start, offset, 5, "dim", FORCE_NL);
  1094. X      obj_nos*=get_bin5(start, offset);
  1095. X      offset+=5;
  1096. X    }
  1097. X  pr_infh(printf("-- array start"));
  1098. X  while(obj_nos--)
  1099. X    offset+=print_obj(start, offset, cur_prolog);
  1100. X  pr_infh(printf("\n-- array end"));
  1101. X  return(length);
  1102. X}
  1103. X
  1104. Xint print_xlibname(start, offset)
  1105. X     unsigned char *start;
  1106. X     int offset;
  1107. X{
  1108. X  printf("XLIB %dd %dd\n", get_binx(start, offset, 3), get_binx(start, offset+3, 3));
  1109. X  return(XLIBNAME_L);
  1110. X}
  1111. X
  1112. X
  1113. X
  1114. Xint print_library(start, offset)
  1115. X     unsigned char *start;
  1116. X     int offset;
  1117. X{
  1118. X  int *linkme, *linkbase, oldoffs=offset;
  1119. X  int  lts, nts, loop, loop2;
  1120. X  struct {
  1121. X    int libno, hashoffs, msgoffs, linkoffs, configoffs
  1122. X    } libinfo;
  1123. X  int length=get_bin5(start, offset);
  1124. X  offset+=print_size(start, offset);
  1125. X  print_beg(start, offset, 5, "libname", indentlevel);
  1126. X  offset+=print_ascix(start, offset);
  1127. X  print_beg(start, offset, 3, "libnum", FORCE_NL);
  1128. X  libinfo.libno=get_binx(start, offset, 3);
  1129. X  offset+=3;
  1130. X
  1131. X  print_beg(start, offset, 5, "hash", FORCE_NL);
  1132. X  libinfo.hashoffs=get_bin5(start, offset)+offset;
  1133. X  offset+=5;
  1134. X  
  1135. X  print_beg(start, offset, 5, "msg", FORCE_NL);
  1136. X  libinfo.msgoffs=get_bin5(start, offset)+offset;
  1137. X  offset+=5;
  1138. X  
  1139. X  print_beg(start, offset, 5, "link", FORCE_NL);
  1140. X  libinfo.linkoffs=get_bin5(start, offset)+offset;
  1141. X  offset+=5;
  1142. X  
  1143. X  print_beg(start, offset, 5, "config", FORCE_NL);
  1144. X  libinfo.configoffs=get_bin5(start, offset)+offset;
  1145. X  offset+=5;
  1146. X  
  1147. X  if (libinfo.msgoffs!=0x24+oldoffs)
  1148. X    {
  1149. X      pr_infh(printf("-- msg table"));
  1150. X      print_block(start, libinfo.msgoffs);
  1151. X    }
  1152. X
  1153. X  pr_infh(printf("-- hash table"));
  1154. X  libinfo.hashoffs+=print_beg(start, libinfo.hashoffs, 5, "hashtable", FORCE_NL);
  1155. X  libinfo.hashoffs+=print_size(start, libinfo.hashoffs);
  1156. X  for (loop=0; loop<16; loop++)
  1157. X    {
  1158. X      print_beg(start, libinfo.hashoffs, 5, "hashoffs", indentlevel);
  1159. X      printf("Entry %x", loop);
  1160. X      if (get_bin5(start, libinfo.hashoffs) != 0)
  1161. X    printf(" at %x\n", libinfo.hashoffs+get_bin5(start, libinfo.hashoffs));
  1162. X      else
  1163. X    printf(" nonexistant\n");
  1164. X      libinfo.hashoffs+=5;
  1165. X    }
  1166. X  pr_infh(printf("-- name table"));
  1167. X  print_size(start, libinfo.hashoffs);
  1168. X  nts=libinfo.hashoffs+get_bin5(start, libinfo.hashoffs);
  1169. X  libinfo.hashoffs+=5;
  1170. X  while(nts>libinfo.hashoffs)
  1171. X    {
  1172. X      print_beg(start, offset, 5, "name entry", indentlevel);
  1173. X      libinfo.hashoffs+=print_ascic(start, libinfo.hashoffs);
  1174. X      libinfo.hashoffs+=print_beg(start, libinfo.hashoffs, 3, "xlib", FORCE_NL);
  1175. X    }
  1176. X  pr_infh(printf("-- Config for XLIB %dd", libinfo.libno));
  1177. X  print_block(start, libinfo.configoffs);
  1178. X
  1179. X  pr_infh(printf("-- link table"));
  1180. X  libinfo.linkoffs+=print_beg(start, libinfo.linkoffs, 5, "linktable", FORCE_NL);
  1181. X  print_size(start, libinfo.linkoffs);
  1182. X  lts=get_bin5(start, libinfo.linkoffs);
  1183. X  linkbase=(int *)malloc((lts/5)*sizeof(int));
  1184. X  linkme=linkbase;
  1185. X  libinfo.linkoffs+=5;
  1186. X  loop=0;
  1187. X  while((lts-=5)>0)
  1188. X    {
  1189. X      print_beg(start, libinfo.linkoffs, 5, "linkoffs", indentlevel);
  1190. X      *linkme++=(get_bin5(start, libinfo.linkoffs)+libinfo.linkoffs)&FIVENYBLES;
  1191. X      printf("xlib %dd at %X\n", loop,*(linkme-1));
  1192. X      libinfo.linkoffs+=5;
  1193. X      loop++;
  1194. X    }
  1195. X  linkme=linkbase;
  1196. X  for (loop2=0; loop2<loop; loop2++)
  1197. X    {
  1198. X      pr_infh(printf("-- Code for XLIB %dd %dd", libinfo.libno, loop2));
  1199. X      print_block(start, *linkme++);
  1200. X    }
  1201. X  free(linkbase);
  1202. X  return(length);
  1203. X}
  1204. X      
  1205. X
  1206. X
  1207. Xint print_block(start, offset)
  1208. X     unsigned char *start;
  1209. X     int offset;
  1210. X{
  1211. X  int  oldoff=offset;
  1212. X  int cur_prolog=get_bin5(start, offset);
  1213. X  int cur_prolog_no=find_prolog(cur_prolog);
  1214. X  indentlevel+=2;
  1215. X
  1216. X  if (cur_prolog_no!=0)
  1217. X    {
  1218. X      print_beg(start, offset, 5, prologinfo[cur_prolog_no].name , indentlevel);
  1219. X      printf("%s", prologinfo[cur_prolog_no].printname);
  1220. X      offset+=5;
  1221. X      offset+=print_obj(start, offset, cur_prolog);
  1222. X    }
  1223. X  else
  1224. X    {
  1225. X      print_beg(start, offset, 5, "romobj" , indentlevel);
  1226. X      printf("%s", get_infostr(cur_prolog));
  1227. X      puts("");
  1228. X      offset+=5;
  1229. X
  1230. X    }
  1231. X  indentlevel-=2;
  1232. X  return(offset-oldoff);
  1233. X}
  1234. X
  1235. X
  1236. Xmain(argc,argv)
  1237. X     int argc;
  1238. X     char *argv[];
  1239. X{
  1240. X  int retval, filesize=0;
  1241. X  init_info();
  1242. X
  1243. X  if (argc==2) 
  1244. X    printf("Scanning %s\n", argv[1]);
  1245. X  else
  1246. X    printf("erraneous arguments\n");
  1247. X  filesize=readin(argv[1]);
  1248. X  myoffset+=print_hps(myfilearr, myoffset,  8);
  1249. X  printf("\n");
  1250. X  while ((2*filesize)>myoffset)
  1251. X    {
  1252. X      myoffset+=print_block(myfilearr, myoffset);
  1253. X    }
  1254. X  printf("\n\n####END\n");
  1255. X}
  1256. END_OF_unthread.c
  1257. if test 17058 -ne `wc -c <unthread.c`; then
  1258.     echo shar: \"unthread.c\" unpacked with wrong size!
  1259. fi
  1260. # end of overwriting check
  1261. fi
  1262. if test -f unthread.h -a "${1}" != "-c" ; then 
  1263.   echo shar: Will not over-write existing file \"unthread.h\"
  1264. else
  1265. echo shar: Extracting \"unthread.h\" \(1006 characters\)
  1266. sed "s/^X//" >unthread.h <<'END_OF_unthread.h'
  1267. X
  1268. X#define SYSTEM_BINARY    0x02911
  1269. X#define REAL_NUMBER    0x02933
  1270. X#define LONG_REAL    0x02955
  1271. X#define COMPLEX        0x02977
  1272. X#define LONG_COMPLEX    0x0299d    
  1273. X#define CHARACTER    0x029bf    
  1274. X#define ARRAY        0x029e8    
  1275. X#define LINKED_ARRAY    0x02a0a    
  1276. X#define STRING        0x02a2c    
  1277. X#define BINARY_INT    0x02a4e    
  1278. X#define LIST        0x02a74    
  1279. X#define DIRECTORY    0x02a96    
  1280. X#define ALGEBRAIC    0x02ab8    
  1281. X#define UNIT        0x02ada    
  1282. X#define TAGGED        0x02afc    
  1283. X#define GRAPHIC        0x02b1e    
  1284. X#define LIBRARY        0x02b40    
  1285. X#define BACKUP        0x02b62    
  1286. X#define LIBRARY_DATA    0x02b88    
  1287. X#define PROGRAM        0x02d9d    
  1288. X#define CODE        0x02dcc    
  1289. X#define GLOBAL_NAME    0x02e48    
  1290. X#define LOCAL_NAME    0x02e6d    
  1291. X#define XLIB_NAME    0x02e92    
  1292. X
  1293. X#define FORCE_NL -1
  1294. X#define FIVENYBLES 0xfffff
  1295. X#define INFOFIELD_L 15
  1296. X#define WHOLE_INFOFIELD 0
  1297. X
  1298. X
  1299. X#define REAL_L 16
  1300. X#define XLIBNAME_L 6
  1301. X
  1302. X#define REAL_FORM12 16
  1303. X#define REAL_FORM15 19
  1304. X#define MAGIC_MINUS 9
  1305. X
  1306. X#define END_OF_LIST 0x0312b
  1307. X#define END_OF_ALGEBRAIC 0x0312b
  1308. X#define END_OF_PROGRAM 0x0312b
  1309. X#define END_OF_LIBRARYDATA 0x0312b
  1310. X#define END_OF_TAG 0x0312b
  1311. X
  1312. X
  1313. X
  1314. X
  1315. X
  1316. END_OF_unthread.h
  1317. if test 1006 -ne `wc -c <unthread.h`; then
  1318.     echo shar: \"unthread.h\" unpacked with wrong size!
  1319. fi
  1320. # end of overwriting check
  1321. fi
  1322. echo shar: End of shell archive.
  1323. exit 0
  1324. --
  1325. ==============================================================================
  1326. ! Joakim Verona LiTH ! Snail: soergaardsgatan 11 ! Email:                    !
  1327. ! Voice: 013/178107  !        58239 Linkoeping   ! d88joave@kolix.ida.liu.se !
  1328. ==============================================================================
  1329. --
  1330. ==============================================================================
  1331. ! Joakim Verona LiTH ! Snail: soergaardsgatan 11 ! Email:                    !
  1332. ! Voice: 013/178107  !        58239 Linkoeping   ! d88joave@kolix.ida.liu.se !
  1333. ==============================================================================
  1334.  
  1335.